#include<iostream>
#include<iomanip>
#include<string>

using namespace std;

struct MenuItem
{
	string Name;
	double Price;
};

void showMenu()
{
	cout << "(1) Plain Egg" << setw(17) << "$1.45" << endl;
	cout << "(2) Bacon and Egg" << setw(13) << "$2.45" << endl;
	cout << "(3) Muffin" << setw(20) << "$0.99" << endl;
	cout << "(4) French Toast"  << setw(14) << "$1.99" << endl;
	cout << "(5) Fruit Basket" << setw(14) << "$2.49" << endl;
	cout << "(6) Cereal" << setw(20) << "$0.69" << endl;
	cout << "(7) Coffee" << setw(20) << "$0.50" << endl;
	cout << "(8) Tea" << setw(23) << "$0.75" << endl << endl;
}

void getData(MenuItem Order[10], int &OrderCount)
{
    int choice=1;

    while(choice!=0)
    {
        cout << "What is your choice?";
        cin >> choice;

        if(choice==1)
        {
            Order[OrderCount].Name = "Plain Egg";
            Order[OrderCount].Price = 1.45;
        }
        else if(choice==2)
        {
            Order[OrderCount].Name = "Bacon and Egg";
            Order[OrderCount].Price = 2.45;
        }
        else if(choice==3)
        {
            Order[OrderCount].Name = "Muffin";
            Order[OrderCount].Price = 0.99;
        }
        else if(choice==4)
        {
            Order[OrderCount].Name = "French Toast";
            Order[OrderCount].Price = 1.99;
        }
        else if(choice==5)
        {
            Order[OrderCount].Name = "Fruit Basket";
            Order[OrderCount].Price = 2.49;
        }
        else if(choice==6)
        {
            Order[OrderCount].Name = "Cereal";
            Order[OrderCount].Price = 0.69;
        }
        else if(choice==7)
        {
            Order[OrderCount].Name = "Coffee";
            Order[OrderCount].Price = 0.50;
        }
        else if(choice==8)
        {
            Order[OrderCount].Name = "Tea";
            Order[OrderCount].Price = 0.75;
        }
        else if(choice==0)
            break;

        OrderCount++;
    }
}

void printCheck(MenuItem Order[10], int &OrderCount)
{
    double sum=0;
    
    for(int i=0; i<OrderCount; i++)
    {
        cout << Order[i].Name << "\t\t" << Order[i].Price << endl;
        sum = sum + Order[i].Price;
    }

    double tax = sum * 0.05;
    cout << "Your tax is: " << tax << endl;
    sum = sum + tax;
    cout << "Your total is: " << sum << endl;
}

int AutoDownPayment()
{
    int select=1;

    MenuItem Order[10];

	int OrderCount = 0;
	
    cout << "Welcome to Sung's Resturant." << endl << endl;
    cout << "1-Display Menu" << endl;
    cout << "2-Order" << endl;
    cout << "3-Check Out" << endl;
    cout << "0-Quit" << endl;

    while(select!=0)
	{
		if (select==1)
		{
			showMenu();
		}
		else if (select==2)
		{
			getData(Order, OrderCount);
		}
		else if (select==3)
		{
			printCheck(Order, OrderCount);
		}
		else if (select==0)
		{
			cout << "Thank You. Come Again!!" << endl << endl;
			break;
		}
	}

	system ("PAUSE");
	return 0;
}
   